package listbyorder.access001_100.test9;

/**
 * @author code_yc
 * @version 1.0
 * @date 2020/6/6 14:31
 */
public class Solution1 {

    public boolean isPalindrome(int x) {
        if (x < 0) return false;
        // 将x反装
        int y = getRev(x);
        return x == y;
    }

    private int getRev(int x) {
        int ans = 0;
        while (x != 0) {
            int pop = x % 10;
            x /= 10;
            if (ans > Integer.MAX_VALUE / 10) {
                return 0;
            }
            ans = ans * 10 + pop;
        }
        return ans;
    }
}
